/**
 * 
 */
package net.empego.web.dao;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import net.empego.zkcdi.context.ExecutionScoped;

/**
 * @author Thomas
 * 
 */
@ExecutionScoped
public class EntityManagerProvider {

	// @PersistenceUnit(name = "primary-non-jta")
	// private EntityManagerFactory emf;

	@PersistenceContext(name = "primary-non-jta")
	private EntityManager em;

	public EntityManager getActiveEntityManager() {
		if (em.getTransaction().isActive() == false) {
			em.getTransaction().begin();
		}
		return em;
	}

	public EntityManager getEntityManager() {
		return em;
	}

}
